package com.wenx.springcamel;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ByteArrayResource;

public class App2 {

    public static void main(String[] args) throws Exception {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("spring-beans.xml");
        //ApplicationContext ctx = SpringContextUtil.getContext();
//        DefaultListableBeanFactory acf = (DefaultListableBeanFactory) ctx.getAutowireCapableBeanFactory();
//
//
//        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
//                "<beans xmlns=\"http://www.springframework.org/schema/beans\""+
//                "       xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""+
//                "       xmlns:cxf=\"http://camel.apache.org/schema/cxf\""+
//                "       xsi:schemaLocation=\"http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd"+
//                "       http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf-2.19.0-spring.xsd\">"+
//                "   <cxf:cxfEndpoint id=\"sayHell\" address=\"/sayHell\" endpointName=\"s:WebServiceImplPort\" serviceName=\"s:WebServiceImplService\""+
//                "                     wsdlURL=\"WebService.wsdl\" xmlns:s=\"http://service.wenx.com/\"/>"+
//                "</beans>";
//
//        XmlBeanFactory factory = new XmlBeanFactory(new ByteArrayResource(xml.getBytes()));
//        acf.registerBeanDefinition("sayHell", factory.getMergedBeanDefinition("sayHell"));
//        try {
//            context.addRoutes(new RouteBuilder() {
//                @Override
//                public void configure() throws Exception {
//                    from("cxf:bean:helloWorld?dataFormat=MESSAGE").id("routetest1").to("bean:enrichBean")
//                            .to("http://localhost:9000/helloWorld?throwExceptionOnFailure=false");
//                }
//            });
//            context.startRoute("routetest1");
            ctx.start();
        System.in.read();
    }
}
